module.exports = {
  apps: [
    {
      name: 'user',
      script: '../user-graphql-server/src/index.js',
      // Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/
      args: '',
      instances: 1,
      autorestart: true,
      watch: false,
      max_memory_restart: '1G',
      exec_mode: 'cluster',
      output: './logs/output.log',
      error: './logs/error.log',
      log_date_format: 'YYYY-MM-DD HH:mm:ss',
      kill_timeout: 1600,
      wait_ready: true,
      listen_timeout: 3000,
      env: {
        NODE_ENV: 'development',
        PORT: 4001
      },
      env_production: {
        NODE_ENV: 'production'
      }
    },
    {
      name: 'role',
      script: '../role-graphql-server/src/index.js',
      // Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/
      args: '',
      instances: 1,
      autorestart: true,
      watch: false,
      max_memory_restart: '1G',
      exec_mode: 'cluster',
      output: './logs/output.log',
      error: './logs/error.log',
      log_date_format: 'YYYY-MM-DD HH:mm:ss',
      kill_timeout: 1600,
      wait_ready: true,
      listen_timeout: 3000,
      env: {
        NODE_ENV: 'development',
        PORT: 4002
      },
      env_production: {
        NODE_ENV: 'production'
      }
    },
    {
      name: 'menu',
      script: '../menu-graphql-server/src/index.js',
      // Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/
      args: '',
      instances: 1,
      autorestart: true,
      watch: false,
      max_memory_restart: '1G',
      exec_mode: 'cluster',
      output: './logs/output.log',
      error: './logs/error.log',
      log_date_format: 'YYYY-MM-DD HH:mm:ss',
      kill_timeout: 1600,
      wait_ready: true,
      listen_timeout: 3000,
      env: {
        NODE_ENV: 'development',
        PORT: 4003
      },
      env_production: {
        NODE_ENV: 'production'
      }
    },
    {
      name: 'organization',
      script: '../organization-graphql-server/src/index.js',
      // Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/
      args: '',
      instances: 1,
      autorestart: true,
      watch: false,
      max_memory_restart: '1G',
      exec_mode: 'cluster',
      output: './logs/output.log',
      error: './logs/error.log',
      log_date_format: 'YYYY-MM-DD HH:mm:ss',
      kill_timeout: 1600,
      wait_ready: true,
      listen_timeout: 3000,
      env: {
        NODE_ENV: 'development',
        PORT: 4004
      },
      env_production: {
        NODE_ENV: 'production'
      }
    },
    {
      name: 'auth',
      script: 'src/index.js',
      // Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/
      args: '',
      instances: 1,
      autorestart: true,
      watch: false,
      max_memory_restart: '1G',
      exec_mode: 'cluster',
      output: './logs/output.log',
      error: './logs/error.log',
      log_date_format: 'YYYY-MM-DD HH:mm:ss',
      kill_timeout: 1600,
      wait_ready: true,
      listen_timeout: 3000,
      env: {
        NODE_ENV: 'development',
        PORT: 4000
      },
      env_production: {
        NODE_ENV: 'production'
      }
    }
  ],

  deploy: {
    production: {
      user: 'node',
      host: '212.83.163.1',
      ref: 'origin/master',
      repo: 'git@github.com:repo.git',
      path: '/var/www/production',
      'post-deploy':
        'npm install && pm2 reload ecosystem.config.js --env production'
    }
  }
}
